package cn.glutnn.mapper;

import cn.glutnn.entity.dto.ReviewDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.glutnn.entity.FoodReviews;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * (FoodReviews)表数据库访问层
 *
 * @author msh
 * @since 2024-12-14 17:00:37
 */
@Mapper
public interface FoodReviewsMapper extends BaseMapper<FoodReviews> {
    @Select("SELECT " +
            "r.id, r.order_id, r.user_id, r.rating, r.comment, r.created_time, " +
            "u.username, u.avatar as userAvatar " +
            "FROM food_reviews r " +
            "LEFT JOIN user u ON r.user_id = u.id " +
            "WHERE r.business_id = #{businessId} " +
            "ORDER BY r.created_time DESC")
    List<ReviewDTO> getBusinessReviewsWithUserInfo(@Param("businessId") Integer businessId);
}

